package question1.test2;
/*张三,男,20,79.5
        李四,女,21,80.2
        王五,男,22,77.9
        周六,男,20,55.8
        赵七,女,21,99.9*/

import java.awt.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

public class Test {
    public static void main(String[] args) {
        Student student1 = new Student("李四", "女", "21", "80.2");
        Student student2 = new Student("王五", "男", "22", "77.9");
        Student student3 = new Student("周六", "男", "20", "55.8");
        Student student4 = new Student("赵七", "女", "21", "99.9");
        Student student5 = new Student("张三", "男", "20", "79.5");
        ArrayList<Student> list = new ArrayList<>(List.of(student1,student2,student3,student4,student5));
        BigDecimal sum=new BigDecimal(0);
        for (Student student : list) {
            sum=sum.add(BigDecimal.valueOf(Double.parseDouble(student.getFraction())));
        }
        double average=sum.divide(BigDecimal.valueOf(list.size()),2,BigDecimal.ROUND_HALF_UP).doubleValue();
        System.out.println("average="+average);
    }
}
